package com.abc.studentmanager.service.Impl;

import com.abc.studentmanager.domain.Location;
import com.abc.studentmanager.mapper.LocationMapper;
import com.abc.studentmanager.service.LocationService;
import com.abc.studentmanager.util.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @Classname
 * @Description
 * @Created
 */
@Service
public class LocationServiceImpl implements LocationService {

    @Autowired
    private LocationMapper locationMapper;

    @Override
    public PageBean<Location> queryPage(Map<String, Object> paramMap) {
        PageBean<Location> pageBean = new PageBean<>((Integer) paramMap.get("pageno"),(Integer) paramMap.get("pagesize"));

        Integer startIndex = pageBean.getStartIndex();
        paramMap.put("startIndex",startIndex);
        List<Location> datas = locationMapper.queryList(paramMap);
        pageBean.setDatas(datas);

        Integer totalsize = locationMapper.queryCount(paramMap);
        pageBean.setTotalsize(totalsize);
        return pageBean;
    }

    @Override
    public int addClazz(Location location) {
        return locationMapper.addLocation(location);
    }

    @Override
    @Transactional
    public int deleteClazz(List<Integer> ids) {
        return locationMapper.deleteLocation(ids);
    }

    @Override
    public int editClazz(Location location) {
        return locationMapper.editLocation(location);
    }

    @Override
    public Location findByName(String clazzName) {
        return locationMapper.findByName(clazzName);
    }

}
